package cn.iocoder.yudao.module.wine.dal.mysql.supplycount;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.wine.controller.app.supplycount.vo.AppSupplyCountPageReqVO;
import cn.iocoder.yudao.module.wine.controller.app.supplycount.vo.AppSupplyCountRespVO;
import cn.iocoder.yudao.module.wine.dal.dataobject.supplycount.SupplyCountDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wine.controller.admin.supplycount.vo.*;

/**
 * 酒类行情日K Mapper
 *
 * @author 管理员
 */
@Mapper
public interface SupplyCountMapper extends BaseMapperX<SupplyCountDO> {

    default PageResult<SupplyCountDO> selectPage(SupplyCountPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SupplyCountDO>()
                .eqIfPresent(SupplyCountDO::getConfigId, reqVO.getConfigId())
                .eqIfPresent(SupplyCountDO::getInfoTitle, reqVO.getInfoTitle())
                .eqIfPresent(SupplyCountDO::getFirstPrice, reqVO.getFirstPrice())
                .eqIfPresent(SupplyCountDO::getMaxPrice, reqVO.getMaxPrice())
                .eqIfPresent(SupplyCountDO::getMinPrice, reqVO.getMinPrice())
                .eqIfPresent(SupplyCountDO::getLastPrice, reqVO.getLastPrice())
                .betweenIfPresent(SupplyCountDO::getCountTime, reqVO.getCountTime())
                .betweenIfPresent(SupplyCountDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SupplyCountDO::getId));
    }

    default PageResult<AppSupplyCountRespVO> appSelectPage(AppSupplyCountPageReqVO reqVO){
        return selectJoinPage(reqVO,AppSupplyCountRespVO.class, new MPJLambdaWrapperX<SupplyCountDO>()
                .eqIfPresent(SupplyCountDO::getConfigId, reqVO.getConfigId())
                .eqIfPresent(SupplyCountDO::getInfoTitle, reqVO.getInfoTitle())
                .eqIfPresent(SupplyCountDO::getFirstPrice, reqVO.getFirstPrice())
                .eqIfPresent(SupplyCountDO::getMaxPrice, reqVO.getMaxPrice())
                .eqIfPresent(SupplyCountDO::getMinPrice, reqVO.getMinPrice())
                .eqIfPresent(SupplyCountDO::getLastPrice, reqVO.getLastPrice())
                .betweenIfPresent(SupplyCountDO::getCountTime, reqVO.getCountTime())
                .betweenIfPresent(SupplyCountDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(SupplyCountDO::getCreateTime));
    }
}
